/*************************************************************************
	> File Name: sstream_test.cc
	> Author: likang
	> Mail:  
	> Created Time: 2014年12月07日 星期日 12时02分50秒
 ************************************************************************/

#include<iostream>
#include<sstream>

using namespace std;

int main(void) {
	/*getline得到每一行的输入,借助istringstream得到每一行的每个单词*/
	string line, word;
	while (getline(cin, line)) {
		istringstream stream(line);
		while (stream >> word) {
			cout << word << "#" << endl;
		}
	}

	/*stringsream 提供的转换和格式化数据*/
	int va1 = 512;
	int va2 = 256;
	ostringstream format_message;
	format_message << "va1: " << va1 << "\nva2: " << va2 << "\n";
	string s;
	s = format_message.str();
	cout << s << endl;
	istringstream input_string(s);
	int va3, va4;
	string dump;
	input_string >> dump >> va3 >> dump >> va4;
	cout << "dump:" << dump << endl;
	cout << va3 << " " << va4 << endl;
	return 0;
}
